package com.esri.core.internal.tasks.ags;

import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.io.UserCredentials;
import com.esri.core.portal.PortalFolder;
import com.esri.core.portal.PortalItem;
import com.esri.core.portal.PortalUserContent;
import java.util.ArrayList;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class ah extends com.esri.core.internal.tasks.d<PortalUserContent> {
    private static final long serialVersionUID = 1;

    public ah(al alVar, String str, String str2, String str3, UserCredentials userCredentials) {
        this(alVar, str, str2, str3, userCredentials, null);
    }

    public ah(al alVar, String str, String str2, String str3, UserCredentials userCredentials, TaskListener<PortalUserContent> taskListener) {
        super(alVar, a(str, str2, str3), userCredentials, taskListener);
    }

    private static final String a(String str, String str2, String str3) {
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        sb.append("/content/users/");
        sb.append(str2);
        if (str3 != null && !"".equals(str3.trim())) {
            sb.append("/");
            sb.append(str3);
        }
        return sb.toString();
    }

    @Override // com.esri.core.internal.tasks.a
    /* renamed from: a */
    public PortalUserContent execute() throws Exception {
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        JsonParser a = com.esri.core.internal.io.handler.h.a(this.serviceURL, this.actionInput.generateRequestParams(), getServiceCredentials());
        if (com.esri.core.internal.util.d.c(a)) {
            while (a.nextToken() != JsonToken.END_OBJECT) {
                String currentName = a.getCurrentName();
                a.nextToken();
                if (currentName.equals("username")) {
                    a.skipChildren();
                } else if (currentName.equals("currentFolder")) {
                    a.skipChildren();
                } else if (currentName.equals("items")) {
                    while (a.nextToken() != JsonToken.END_ARRAY) {
                        arrayList.add(PortalItem.fromJson(a, ((al) getActionInput()).a));
                    }
                } else if (currentName.equals("folders")) {
                    while (a.nextToken() != JsonToken.END_ARRAY) {
                        arrayList2.add(PortalFolder.fromJson(a));
                    }
                }
            }
        }
        return new PortalUserContent(arrayList, arrayList2);
    }
}
